<?php
//ajax response
$isAdmin = ($current_user['auth_type'] == 'administrator');

$headers = ($isAdmin) ? array_merge(array('ID', 'Member Info'), array_keys($actions)) : array('ID', 'Member Info', ucwords($current_user['auth_type']) . ' Actions');

echo "<table>\n";
echo $html->tableHeaders($headers);

$data = array();
foreach($members as $member) {
	$m = $member['Member'];
	$p = $member['Producer'];
	
	$actionsULs = array();
	if ($isAdmin) {
	  foreach($actions as $auth_level) {
	  	$actionList = "<ul>";
	  	foreach($auth_level as $auth) {
	  		if (isset($auth[3])) {
	  			$m[$auth[2]] = ($auth[3] == AUTH_PROD) ? $p[$auth[2]] : $m[$auth[3]][$auth[2]];
	  		}
	  		$link = (isset($auth[2])) ? $auth[1] . $m[$auth[2]] : $auth[1];
	  		$actionList .= '<li>' . $html->link($auth[0],$link) . "</li>\n";
	  	}
	  	$actionsULs[] = $actionList . "</ul>\n";
	  }
	} else {
	  $actionList = "<ul>";
	  foreach($actions[$current_user['auth_type']] as $auth) {
	  //print_r($auth);
	  	if (isset($auth[3])) {
	  		$m[$auth[2]] = ($auth[3] == AUTH_PROD) ? $p[$auth[2]] : $m[$auth[3]][$auth[2]];
	  	}
	  	$link = (isset($auth[2])) ? $auth[1] . $m[$auth[2]] : $auth[1];
	  	$actionList .= '<li>' . $html->link($auth[0],$link) . "</li>\n";
	  }
	  $actionsULs[] = $actionList . "</ul>\n";
	}
	
	$data[] = array_merge(array($m['member_id'], $this->renderElement('memberVcard',array('m' => $m))), $actionsULs);
	
}
echo $html->tableCells($data);
?>
</table>